import 'package:flutter/material.dart';

class ResultScreen extends StatelessWidget {
  final int score;

  const ResultScreen({super.key, required this.score});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('关卡完成')),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Icon(
              _buildRewardIcon(),
              size: 100,
              color: Colors.amber,
            ),
            const SizedBox(height: 24),
            Text(
              _getRewardMessage(),
              style: const TextStyle(fontSize: 24),
              textAlign: TextAlign.center,
            ),
            const SizedBox(height: 16),
            Text('你的得分: $score', style: const TextStyle(fontSize: 20)),
            const SizedBox(height: 32),
            ElevatedButton(
              onPressed: Navigator.of(context).pop,
              child: const Text('返回关卡选择'),
            )
          ],
        ),
      ),
    );
  }

  IconData _buildRewardIcon() {
    if (score >= 9) {
      return Icons.star_rate;
    } else if (score >= 7) {
      return Icons.local_fire_department;
    } else if (score >= 5) {
      return Icons.emoji_events;
    } else if (score >= 3) {
      return Icons.celebration;
    } else {
      return Icons.sentiment_satisfied;
    }
  }

  String _getRewardMessage() {
    if (score >= 9) {
      return '太棒了！你是数学小天才！🌟';
    } else if (score >= 7) {
      return '做得很好！继续努力！🔥';
    } else if (score >= 5) {
      return '不错哦！再接再厉！🏆';
    } else if (score >= 3) {
      return '有进步！继续加油！🎉';
    } else {
      return '没关系，再来一次试试看！😊';
    }
  }
}